﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Entity.ModelConfiguration;
using System.ComponentModel.DataAnnotations;

using Comswing.Business.Entities;

namespace Comswing.Data.Configuration
{
    internal class SwingConfiguration : EntityTypeConfiguration<Swing>
    {
        public SwingConfiguration()
        {
            HasKey(e => e.Id);

            Property(e => e.Id)
                .IsRequired()
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.Identity)
                .HasColumnName("Id");

            Property(e => e.Active)
                .IsRequired()
                .HasColumnName("Active");

            Property(e => e.StartDate)
                .IsRequired()
                .HasColumnName("StartDate");

            Property(e => e.FinishDate)
                .IsRequired()
                .HasColumnName("FinishDate");

            Property(e => e.SwingDivideNumber)
                .IsRequired()
                .HasColumnName("SwingDivideNumber");

            Property(e => e.SwingUnitCash)
                .IsRequired()
                .HasColumnName("SwingUnitCash");

            HasMany(e => e.UserSwings)
                .WithRequired(r => r.Swing);

            Ignore(e => e.TimeLapse);

            ToTable("Swing", "dbo");
        }
    }
}
